package club.itstudio.itouc.controller

import club.itstudio.itouc.core.util.Resource
import club.itstudio.itouc.util.Redis
import org.springframework.web.bind.annotation.CookieValue
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RestController

/**
 * PC端首页
 */
@RestController
class Index (val resource: Resource,
             val redis: Redis){

    @GetMapping("/")
    fun index(@CookieValue(required = false) token: String?): String {
        return if (token == null || !redis.hasJwSession(token))
            resource.template("user/login.html")
        else
            resource.template("user/index.html")
    }
}